import javaService from '../javaHttp'

function handel(data) {
  var params = new URLSearchParams()
  for (const key in data) {
    params.append(key, data[key])
  }
  return params
}

export function department_getByParentId(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontDepartment/departmentTree`,
    method: 'GET',
    isLoading: true,
    params: data
  })
}

export function department_add(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontDepartment/add`,
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}

export function department_del2(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontDepartment/delByIds/${data}`,
    // url: '/hontDepartment/delByIds/' + data,
    method: 'DELETE'
  })
}

export function department_edit(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontDepartment/edit`,
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}

export function department_getByDepartmentId(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontUser/selectUserBuDepartmentId`,
    method: 'GET',
    isLoading: true,
    params: data
  })
}

export function getByParentId(data) {
  return javaService({
    url: `${process.env.VUE_APP_DEV_JAVA_BASE_HOST}/hontDepartment/getByParentId`,
    // url: '/hontDepartment/getByParentId',
    method: 'GET',
    isLoading: true,
    params: data
  })
}
